﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace HardwareLibrary.XMLLibrary
{
    public class XMLOp
    {
        #region 图片XML的创建与读取
        /// <summary>
        /// 创建拍照截图的XML上传文件
        /// </summary>
        /// <param name="xmlFullFileName">截图XML保存的带文件名的全路径</param>
        /// <param name="htable">截图的hashtable</param>
        /// <param name="timeForFolder">Ftp服务器的创建文件夹依据</param>
        public void CreatePicXML(string xmlFullFileName, Hashtable htable, string timeForFolder)
        {
            XMLHelper xmlhp = new XMLHelper();
            Hashtable ht = new Hashtable();
            ht.Add("PicTime", timeForFolder);
            xmlhp.CreateXmlDocument(xmlFullFileName, "CONFIG", "UTF-8");
            xmlhp.InsertNode(xmlFullFileName, "//CONFIG", htable, ht);
            ht.Clear();
        }
        /// <summary>
        /// 截图保存XML的读取
        /// </summary>
        /// <param name="xmlFullFileName">XML文件的全路径</param>
        /// <returns>XML中图片的名称以及图片的截图保存位置</returns>
        public Hashtable ReadPicXML(string xmlFullFileName)
        {
            XMLHelper xmlhp = new XMLHelper();
            return xmlhp.GetXmlNodeChildByXpath(xmlFullFileName, "//CONFIG");
        }
        /// <summary>
        /// 获取XML文件的时间字符串
        /// </summary>
        /// <param name="xmlFullFileName">XML文件的全路径</param>
        /// <param name="seachStr">属性字段KEY值</param>
        /// <returns>返回属性Value</returns>
        public string ReadPicXmlTime(string xmlFullFileName, string seachStr)
        {
            XMLHelper xmlhp = new XMLHelper();
            return xmlhp.GetXmlAttributeValue(xmlFullFileName, "//CONFIG//" + seachStr, "PicTime");
        }
        #endregion
    }
}
